
#include "stdafx.h"
#include "Log_SQLite.h"
#include <fstream>
#include <time.h>


Log_SQLite::Log_SQLite(void)
{
}

Log_SQLite::~Log_SQLite(void)
{
}

//std::auto_ptr<CString> Log_SQLite::GetDayTime()
//{
//	std::auto_ptr<CString> strDT(new CString("["));
//	TCHAR buffer[9];
//	_tstrdate_s(buffer,9);
//	strDT->Append(buffer);
//	_tstrtime_s(buffer,9);
//	strDT->Append(_T(" "));
//	strDT->Append(buffer);
//	strDT->Append(_T("]:"));
//	return strDT;
//}
const char* Log_SQLite::GetDayTimeStr(CString & strTime)
{
	const int SIZE = 30;
	strTime = "[";
	time_t ltime;
	TCHAR buf[SIZE];
	errno_t err;
    time( &ltime );
    err = _tctime_s( buf, SIZE, &ltime );
    if (err != 0)
    {
		strTime += buf;
	}
	strTime +="]";
	return (const char*)strTime;
}
void Log_SQLite::Log_Error(const char* szFileName, const char* szErrorMessage)
{
	if(szFileName==NULL)
		return ;
	ofstream wFile(szFileName,ios::app);
	if(wFile.good())
	{
	    CString ptrDT;
		wFile<< GetDayTimeStr(ptrDT);
		wFile<<szErrorMessage;	
	}
	else
	{
		return ;
	}
	
}
